/**
 *  JSimProd - Java simulation code for production processes
 *  Copyleft Jorge Mira Yagüe <jorge.mira.yague@gmail.com>
 *  Universidad de Alicante 2009
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
package lib.model;

import lib.xml.XMLizable;
import lib.exceptions.InvalidBatchsValueException;

/**
 *
 * @author Jorge Mira Yagüe
 */
public class Restriction implements XMLizable {

    private String itemCategory;
    private int minBatch;
    private int maxBatch;

    public Restriction(String itemCategory, int minBatch, int maxBatch)
            throws InvalidBatchsValueException {
        if (minBatch < 0 || maxBatch <= 0 || maxBatch < minBatch) {
            throw new InvalidBatchsValueException();
        }
        this.itemCategory = itemCategory;
        this.minBatch = minBatch;
        this.maxBatch = maxBatch;
    }

    public String getItemCategory() {
        return itemCategory;
    }

    public int getMaxBatch() {
        return maxBatch;
    }

    public int getMinBatch() {
        return minBatch;
    }

    public String toXML() {
        String result = "<Restriction ";
        result += "itemCategoryName=\"" + itemCategory + "\" ";
        result += "maxBatch=\"" + maxBatch + "\" ";
        result += "minBatch=\"" + minBatch + "\" ";
        result += "/>\n";
        return result;
    }
}
